import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		todoList: [{
				name: '小黑',
			},
			{
				name: '小明',
			},
			{
				name: '小红',
			}
		]
	},
	getters: {

	},
	mutations: {
		delList(state, payload) {
			state.todoList.splice(payload, 1)
		},
		addList(state, payload) {
			state.todoList.splice(payload.index,0,payload.text)
		},
		editList(state, payload) {
			console.log(payload)
			state.todoList[payload.index].name=payload.text.name
		}
	}
})
export default store
